<?php
namespace app\admin\controller;
use think\facade\Db;
use think\Controller;
use think\Request;
use think\facade\Log;
class H5pay extends Controller{
	public function test2(){
		
		$send = send_sms2("18856151031", 1, "123456", "123", "18856151031");
		echo "<pre>";
		var_dump($send);
	}
	public function aliuserid()
	{
		$user_id=request()->get("user_id");
		session("user_id",$user_id);
		$user_community=Db::table("applet_community")
                        ->where("user_id", $user_id)
                        ->find();
        if(empty($user_community))
        {
        	return "错误";
        }
        $community_id=$user_community["community_id"];
		header("Location:https://www.jfzhiwen.com/admin/H5alipay/selectroom?community_id=".$community_id);
		exit;
	}
	
	public function selectroom(){
        $community_id=request()->get("community_id");
        $communityinfo=Db::table("community")->where("id",$community_id)->find();
        if(empty($communityinfo)){
            return "小区信息错误";
        }
        if($communityinfo["auto_jump_v3"]=="1"){
            $v3_community_id=$communityinfo["v3_community_id"];
            $url="https://www.wyjf.zfbzhsq.com/index/".$v3_community_id;
            header("Location:https://www.wyjf.zfbzhsq.com/index/".$v3_community_id);

            exit;
        }

        if($communityinfo["auto_jump_zftpay"]=="1"){
            $v3_community_id=$community_id;
            header("Location:https://www.wuye.zfbzhsq.com/zftpay/index/selectroom?community_id=".$v3_community_id);

            exit;
        }
        //判断是不是微信
        if (strpos($_SERVER['HTTP_USER_AGENT'],'MicroMessenger') !== false ) 
        {
        	
        	$community_id=request()->get("community_id");

            header("Location:https://www.wuye.zfbzhsq.com/admin/H5wxpay/selectroom?community_id=".$community_id);
			exit;
			exit;
        }
        //判断是不是支付宝
        if (strpos($_SERVER['HTTP_USER_AGENT'], 'AlipayClient') !== false) 
        {
			$community_id=request()->get("community_id");

          	header("Location:https://www.wuye.zfbzhsq.com/admin/H5alipay/selectroom?community_id=".$community_id);
			exit;
		}
        //哪个都不是
        return "<div style='text-align:center;color:red;margin-top:50px;font-size:80px'>请使用微信扫码</div>";
      
	}
	
	public function selectroom2(){
        //判断是不是微信
        /*if (strpos($_SERVER['HTTP_USER_AGENT'],'MicroMessenger') !== false ) 
        {
        	
        	$community_id=request()->get("community_id");
            header("Location:https://www.wuye.zfbzhsq.com/admin/H5wxpay2/selectroom?community_id=".$community_id);
			exit;
			exit;
        }*/
        //判断是不是支付宝
        if (strpos($_SERVER['HTTP_USER_AGENT'], 'AlipayClient') !== false) 
        {
			$community_id=request()->get("community_id");
		
          	header("Location:https://www.wuye.zfbzhsq.com/admin/H5alipay2/selectroom?community_id=".$community_id);
			exit;
		}
        //哪个都不是
        return "<div style='text-align:center;color:red;margin-top:50px;font-size:80px'>请使用支付宝扫码</div>";
      
	}
	public function communitycashierpay(){
	   
        //判断是不是支付宝
        if (strpos($_SERVER['HTTP_USER_AGENT'], 'AlipayClient') !== false) 
        {
			$cashier_id=request()->get("cashier_id");
		
          	header("Location:https://www.wuye.zfbzhsq.com/admin/H5alipay/communitycashierselectroom?cashier_id=".$cashier_id);
			exit;
		}
        if (strpos($_SERVER['HTTP_USER_AGENT'],'MicroMessenger') !== false )
        {

            return View::fetch('msgtip/payunable');
        }

        //哪个都不是
        return "<div style='text-align:center;color:red;margin-top:50px;font-size:80px'>请使用支付宝扫码</div>";
	}
	public function gatepay(){
        //判断是不是微信
        if (strpos($_SERVER['HTTP_USER_AGENT'],'MicroMessenger') !== false ) 
        {
        	
        	$gateid=request()->get("gateid");
            header("Location:https://www.wuye.zfbzhsq.com/admin/H5wxpay/gatepay?gateid=".$gateid);
			exit;
			exit;
        }
        //判断是不是支付宝
        if (strpos($_SERVER['HTTP_USER_AGENT'], 'AlipayClient') !== false) 
        {
			$gateid=request()->get("gateid");
		
          	header("Location:https://www.wuye.zfbzhsq.com/admin/H5alipay/gatepay?gateid=".$gateid);
			exit;
		}
        //哪个都不是
        return "<div style='text-align:center;color:red;margin-top:50px;font-size:80px'>请使用微信扫码</div>";
      
	}
	
	public function gatepay2(){
        //判断是不是微信
        if (strpos($_SERVER['HTTP_USER_AGENT'],'MicroMessenger') !== false ) 
        {
        	
        	$gateid=request()->get("gateid");
            header("Location:https://www.wuye.zfbzhsq.com/admin/H5wxpay/gatepay2?gateid=".$gateid);
			exit;
			exit;
        }
        //判断是不是支付宝
        if (strpos($_SERVER['HTTP_USER_AGENT'], 'AlipayClient') !== false) 
        {
			$gateid=request()->get("gateid");
		
          	header("Location:https://www.wuye.zfbzhsq.com/admin/H5alipay/gatepay2?gateid=".$gateid);
			exit;
		}
        //哪个都不是
        return "<div style='text-align:center;color:red;margin-top:50px;font-size:80px'>请使用微信扫码</div>";
      
	}
	

	public function test(){
		session(null);
	}
}